<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<title>JINMEI NOW System</title>
	<link rel="stylesheet" href="<%=request.getContextPath()%>/public/css/styles.css" />
	<link rel="stylesheet" href="<%=request.getContextPath()%>/public/css/simple.css" />
	<script type="text/javascript" src="<%=request.getContextPath()%>/public/jquery-ui-1.10.3.custom/js/jquery-1.9.1.js"></script>
	<script type="text/javascript">
	$(document).ready(
		function(){
			$('input[type=text]:not(div.typenames input[type=text])')
			.bind('blur', function(event) {
				var reg = /^([0-9]|0[0-9]|1[0-9]|2[0-3])([:|.][0-5]?[0-9])*$/
				var value = $(this).val();
				var str = value;
				if (reg.test(str)) {
					str = str.replace(".", ":");
					if (str.length == 1 || str.length == 2) {
						str = str + ":00";
					}
					var hour = str.split(":")[0];
					if (hour.length == 1) {
						str = "0" + str;
					}
					var minutes = str.split(":")[1];
					if (minutes.length == 1) {
						str = str.split(":")[0] + ":0" + minutes;
					}
				
					$(this).val(str);
				} else {
					$(this).css("background-color","#FFD9EC");
				}})
			.bind('focus', function(event) {
				$(this).css("background-color","#ffffff");
			});
			
			$('form').removeAttr('onsubmit').bind('submit', function(event) {
				var reg = /^([0-9]|0[0-9]|1[0-9]|2[0-3])([:][0-5][0-9])$/;
				var valid = true;
				$('input[type=text]:not(div.typenames input[type=text])')
				.each(function() {
					var value = $(this).val();
					if (!reg.test(value)) {
						$(this).css("background-color","#FFD9EC");
						valid = false;
					}
				});
				return valid;
			});
			
			// consistent label name with what it is in textfiled.
			$('div.typenames input[type=text]:eq(0)')
			.bind('blur', function(event) {
				var name = $(this).val();
				$('#atypenamelabel').html(name);
			});
			$('div.typenames input[type=text]:eq(1)')
			.bind('blur', function(event) {
				var name = $(this).val();
				$('#btypenamelabel').html(name);
			});
		}
	);
 	</script>
</head>
<body>
	<div id="document">	
			<div id="head">
				<table cellspacing="0" cellpadding="0" border="0" width="100%">
					<tr valign="top">
						<td>
							<!--<a href="#"><img src="../images/monogram.gif" alt="" width="213" height="57" /></a>-->
						</td>
						<td valign="middle">
							<div id="util">								
								<table cellspacing="0" cellpadding="0" border="0">
									<tr valign="middle">
										<td>用户：<s:property value="username"/></td>
										<td>&nbsp;&nbsp;</td>
										<td><a href="logout">退出</a></td>	
									</tr>
								</table>
					  		</div>				
						</td>
					</tr>
				</table>
			</div>
			<div id="nav1">
				<table cellspacing="0" cellpadding="0" border="0">
					<tr valign="middle">
						<td id="searchCell"></td>
						<td><img src="<%=request.getContextPath()%>/public/images/nav1Link.gif" alt="" width="9" height="8" />
							<a href="getWorkScheduleByDate?user_sessionid=<s:property value='%{user_sessionid}'/>">排班管理</a>
						</td>
						<td><img src="<%=request.getContextPath()%>/public/images/nav1Link.gif" alt="" width="9" height="8" /><a href="passwordSettingAction?user_sessionid=<s:property value='%{user_sessionid}'/>">密码设置</a></td>
						<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>					
					</tr>
			    </table>
			</div>
			<table border="0" cellpadding="0" cellspacing="0">
				<tr valign="top">
					<td id="navCell">
						<div  id="nav2">
							<ul class="breadcrumb">
								<li><a href="#">排班作业</a></li>
							</ul>
							<ul class="navitemList">
								<li><a href="wssetting?user_sessionid=<s:property value='%{user_sessionid}'/>">班表设置</a></li>
								<li><a href="getWorkScheduleByDate?user_sessionid=<s:property value='%{user_sessionid}'/>">出勤排班表管理</a></li>
							</ul>
						</div>
					</td>
					<td id="mainCell">
						<h2 id="pageTitle" class="mainTitle">班表设置</h2>
						<s:form>
							<table border="0" cellspacing="1" >
							<tbody>
								<tr>
									<td width="60"></td>
									<td width="150"></td>
									<td width="200"></td>
									<td width="100" align="left">
										<s:submit type="button" value="submit" label="确认" style="width:80"
     					 					cssClass="Submit" theme="simple" id="submit" action="savewssetting"/>
     								</td>
								</tr>
								<s:iterator value="wsSets" status="stat">
									<tr>
										<td></td>
										<td valign="top" height="50">
											<div class="typenames">
												<s:textfield name="wsSets[%{#stat.index}].descr" value="%{descr}"
												 theme="simple" maxlength="20"
												 cssStyle="size:10px; width:45px;text-align:left"/>
												 班设置
											</div>
											<s:hidden name="wsSets[%{#stat.index}].id" value="%{id}"></s:hidden>
											<s:hidden name="wsSets[%{#stat.index}].workingType" value="%{workingType}"></s:hidden>
										</td>
										<td valign="bottom">
											开始时间: <s:textfield name="wsSets[%{#stat.index}].workingStartTime" value="%{workingStartTime}"
												 theme="simple" maxlength="5" 
												 cssStyle="size:10px; width:45px;text-align:right"
												 onblur="validate(this)"
												 />
											<br>
											<br>
											结束时间: <s:textfield name="wsSets[%{#stat.index}].workingEndTime" value="%{workingEndTime}" 
												 theme="simple" maxlength="5" 
												 cssStyle="size:10px; width:45px;text-align:right"
												 onblur="validate(this)"
												 />
										</td>
										<td></td>
									</tr>
									<tr>
										<td colspan="4"></td>
									</tr>
								</s:iterator>
								<tr>
									<td></td>
									<td colspan="3">
										<div>
											<s:checkbox name="abselectflag" value="abselectflag" theme="simple"></s:checkbox>
											是否允许员工同时出勤
											<span id="atypenamelabel"><s:property value="wsSets[0].descr"/></span>班、
											<span id="btypenamelabel"><s:property value="wsSets[1].descr"/></span>班？
										</div>
									</td>
								</tr>
							</tbody>
							</table>
	 						<s:hidden name="user_sessionid" value="%{user_sessionid}"></s:hidden>
						</s:form>
					</td>
				</tr>
		  	</table>	
			<div id="foot">
				<p>Copyright JINMEINOW  2013</p>
			</div>
		</div>
</body>
</html>